package com.gxg.web.Controller;

import com.gxg.common.R;
import com.gxg.common.logger.Logger;
import com.gxg.web.Base.BaseController;
import com.gxg.web.dto.XUserDto;
import com.gxg.web.business.LoginOpearater;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Date;

/**
 * Created by guxiaoguang on 2018/4/23.
 */
@Api(description = "首页Login")
@Controller
@RequestMapping(value = "/xuebai/manager")
public class managerController extends BaseController {

    @Autowired
    private LoginOpearater loginOpearater;

    @ApiOperation(value = "用户登录接口")
    @RequestMapping(value = "login", method = RequestMethod.POST, produces = "application/json")
    public @ResponseBody
    R login(@Valid @RequestBody XUserDto dto, BindingResult result, HttpServletRequest request)
            throws Exception {
        Logger.info("-------用户【" + dto.toString() + "】 后台登陆 , 登陆时间：" + new Date() + "--------");
        // 验证参数合法性
        verify(result, request, dto);
        R r = loginOpearater.userLogin(dto);
        return r;
    }



    public static void  main(String[] arg){
        long start = System.nanoTime();
        System.out.println(start);
    }
}
